package book;



/**
 * Created with IntelliJ IDEA.
 * Description:定义书类
 * User: 86183
 */
public class Book {
    //封装成员变量
    private String name; //书名
    private String author; //作者
    private int price; //价格
    private String type; //类型
    private boolean borrow; //是否借出 默认为 未借出

    //构造方法
    public Book(String name, String author, int price, String type) {
        this.name = name;
        this.author = author;
        this.price = price;
        this.type = type;
    }

    /**
     * 成员变量被private封装，其他类可以通过getter和setter方法来访问封装成员变量
     * @return
     */
    //getter和setter方法
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public boolean getBorrow() {
        return borrow;
    }

    public void setBorrow(boolean borrow) {
        this.borrow = borrow;
    }

    @Override
    public String toString() {
        return "Book{" +
                "书名='" + name + '\'' +
                ", 作者='" + author + '\'' +
                ", 价格=" + price +
                ", 类型='" + type + '\'' +
                ((borrow == true)?",已借出":",未借出" )+
                '}';
    }
}
